package dro.id.gl.engine.graphics;

import java.util.LinkedList;

/**
 * @author peeweek
 *
 */
public class SpriteBatch {

	/**
	 * Public Members
	 */
	public static final int 			SB_BLEND_NONE = 0;
	public static final int 			SB_BLEND_ADD = 1;
	public static final int 			SB_BLEND_BLEND = 2;
	
	/**
	 * Private Members
	 */
	private Shader 						m_oShader;
	private int							m_iSpriteBlendMode;
	
	private LinkedList<Sprite>			m_oSpriteQueue;
	private boolean 					m_bIsLocked;
	
	
	/**
	 * Builds a new SpriteBatch. A Sprite Batch is a set of 2D Sprites that will be rendered on a single pass based on an arbitrary sort.
	 * @param p_iSpriteBatchMode	The Blend Mode to be used with the Batch, possible values are : SB_BLEND_NONE, SB_BLEND_ADD, SB_BLEND_BLEND
	 * @param p_iSpriteBlendMode	The Batch Mode: SB_STATIC only allows unmoving sprites, SB_DYNAMIC updates sprites once every frame to allow movement.
	 * @param p_oShader				The Shader to be used with this SpriteBatch
	 */
	public SpriteBatch(int p_iSpriteBlendMode, Shader p_oShader) {
		
		this.m_oShader 					= p_oShader;
		this.m_iSpriteBlendMode 		= p_iSpriteBlendMode;
		this.m_bIsLocked				= false;
		this.m_oSpriteQueue				= new LinkedList<Sprite>();
	}
	
	public void AddSprite(Sprite p_Sprite) throws SpriteBatchAlreadyLockedException {
		
		if(! this.m_bIsLocked){
			
			this.m_oSpriteQueue.offer(p_Sprite);
			
		} else 
			throw new SpriteBatchAlreadyLockedException();
		
		
	}
	
	public void Finalize() {
		
		if(!this.m_bIsLocked) {
			this.m_bIsLocked = true;
			this.RequestBufferUpdate();
		}
	}
	
	
	public void RequestBufferUpdate() {
		
	}
	
	public void Render() {
		
	}
	
	
}
